package com.lovo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lovo.bean.SysUser;
import com.lovo.mapper.SysUserMapper;
import com.lovo.service.ISysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * ?û?? 服务实现类
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {


    @Override
    public SysUser login(String name, String pwd) {
        QueryWrapper<SysUser> qw = new QueryWrapper<>();
        qw.eq("userName", name);
        qw.eq("userPwd", pwd);
        return baseMapper.selectOne(qw);

    }

    @Override
    public void updateMoneyByUserId(Integer id, Integer money) {
        SysUser user = baseMapper.selectById(id);
        user.setSavemoney(user.getSavemoney()+money);
        baseMapper.updateById(user);
    }

    @Override
    public SysUser findUserById(Integer id) {
        return baseMapper.selectById(id);
    }
}
